package com.cloudcc.mobile.adapter;

import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;

import com.cloudcc.cloudframe.adapter.NewCommonAdapter;
import com.cloudcc.cloudframe.adapter.ViewHolder;
import com.cloudcc.mobile.R;
import com.cloudcc.mobile.entity.NearByFilterEntity;
import com.cloudcc.mobile.entity.TwoOb;

import static com.cloudcc.mobile.view.activity.NearByMapScreenActivity.nearbySelect1;
import static com.cloudcc.mobile.view.activity.NearByMapScreenActivity.nearbySelect2;

/**
 * Created by lin on 2017/7/7.
 */

public class NearByScreenAdapter extends NewCommonAdapter {

    private int adapterMark = 1;
    private int seleteItem = -1;
    private boolean isfrist;

    public NearByScreenAdapter(Context mContext, int adapterMark) {
        super(mContext);
        this.adapterMark = adapterMark;
    }

    @TargetApi(Build.VERSION_CODES.M)
    @Override
    public void convert(ViewHolder holder, Object o, int position) {
        if(adapterMark == 1){//左边的listivew
            NearByFilterEntity entity = (NearByFilterEntity) o;
            holder.setBg(R.id.near_by_screen_item_tv,R.color.white);
            holder.setTextcolor(R.id.near_by_screen_item_tv , mContext.getResources().getColor(R.color.color_17315C));
            holder.setText(R.id.near_by_screen_item_tv , entity.onename);
            holder.setTextLine(R.id.near_by_screen_item_tv ,2);
            if(seleteItem == position){
                holder.setBg(R.id.near_by_screen_item_tv,R.color.color_F4F6F9);
            }if(nearbySelect1 == position && isfrist){
                holder.setBg(R.id.near_by_screen_item_tv,R.color.color_F4F6F9);
                holder.setTextcolor(R.id.near_by_screen_item_tv , mContext.getResources().getColor(R.color.color_187ED7));
            }
        }else{//右边的listview
            TwoOb twoOb = (TwoOb) o;
            holder.setBg(R.id.near_by_screen_item_tv,R.color.color_F4F6F9);
            holder.setTextcolor(R.id.near_by_screen_item_tv , mContext.getResources().getColor(R.color.color_17315C));
            holder.setText(R.id.near_by_screen_item_tv , twoOb.twoname);
            holder.setTextLine(R.id.near_by_screen_item_tv ,1);
            if(nearbySelect2 == position && isfrist){
                holder.setTextcolor(R.id.near_by_screen_item_tv , mContext.getResources().getColor(R.color.color_187ED7));
            }
        }

    }


    @Override
    public int getLayoutId() {
        return R.layout.nearby_map_screen_item;
    }

    public void setSelete(int seleteitem){
        seleteItem = seleteitem;
    }

    public void setSelete(boolean isfrist){
        this.isfrist = isfrist;
    }
}
